<template>
	<view class="comeInfo2">
		<!-- 设备出库 查看记录 --- 详情页面 -->
		<navBar title="查看详情" goBackUrl="/subpackage-equipment/pages/device/deviceCome/deviceCome" @goBack="goBack"></navBar>
		
		<scroll-view scroll-y="true" class="scroll-box">
			<view class="box2">
				<view class="content uniCollapse">
					<view class="project">
						<image class="image" src="/subpackage-equipment/static/project1.png" mode=""></image>
						<view class="name">
							<view class="t1">{{ projectName || "" }}</view>
							<view class="t2">{{ subProjectName || "" }}</view>
						</view>
					</view>
					
					<view class="box">
						<view class="nav border">
							<view class="name">出库编号</view>
							<view class="value">{{ code || "" }}</view>
						</view>
						
						<view class="nav border">
							<view class="name">设备出库单</view>
							<view class="value width">{{ total || 0 }}</view>
						</view>
				
						<uni-collapse>
							<uni-collapse-item v-for="item in deviceInfoList" title-border="show" :key="item.id" :title="item.name" :value="item.totalNum+''">
								<template v-slot:title>
									<view class="collapse-title">
										<view class="left">
											{{ item.name }}
										</view>
										<view class="right">
											{{ item.totalNum }}
										</view>
									</view>
								</template>
								<view class="center" v-for="value in item.infoList" :key="value.id">
									<view class="item">
										<view class="name">设备编号：</view>
										<view class="value">{{ value.code }}</view>
									</view>
									<view class="item">
										<view class="name">规格型号：</view>
										<view class="value">{{ value.specificationModel }}</view>
									</view>
									<view class="item">
										<view class="name">基地名称：</view>
										<view class="value">{{ value.stationName }}</view>
									</view>
								</view>
							</uni-collapse-item>
						</uni-collapse>
					</view>
				</view>
			</view>
		</scroll-view>
		
	</view>
</template>

<script>
	import navBar from "@/components/navBar/navBar.vue"
	import { getEquipmentListCode } from "@/api/device/deviceOut.js"
	import mixins from "@/utils/mixins.js"
	import uniCollapse from "./../../../components/uni-collapse/components/uni-collapse/uni-collapse.vue";
	export default {
		name: "comeInfo",
		mixins: [mixins],
		components: {
			navBar,uniCollapse
		},
		data() {
			return {
				code: "",      // 出库code
				projectName: "",  // 项目名称
				subProjectName: "",  // 标段和工点名称
				total: "",           // 出库设备总数量
				deviceInfoList: [],  // 设备出库详情列表
			}
		},
		onLoad(option) {
			this.code = option.code
			this.projectName = option.projectName
			this.subProjectName = option.subProjectName
			this.getDeviceInfo(this.code)
			console.log(option)
		},
		methods: {
			getDeviceInfo(code){
				getEquipmentListCode({code}).then(res=>{
					this.total = res.result.length || 0
					let list = res.result.map(item=>({...item, totalNum:1}))
					this.deviceInfoList = this.DelSameObjValue(list, 'name', 'totalNum').map(item=>({id: item.id, name: item.name, totalNum: item.totalNum,infoList: []}))
					this.deviceInfoList.forEach(item=>{
						list.forEach(value=>{
							if(item.name === value.name){
								item.infoList.push(value)
							}
						})
					})
					console.log(res.result,this.deviceInfoList)
				})
			},
			
			goBack(url){
				uni.navigateBack({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.comeInfo2{
		width: 100%;
		height: 100%;
		/* #ifdef MP-WEIXIN */
			padding-top: 200rpx;
		/* #endif */
		.scroll-box{
			max-height: calc(100vh - 170rpx);
			padding-top: 10rpx;
		}
			
		.box2{
			background-color: #f5f7fa;
			padding-top: 30rpx;
			height: calc(100vh - 170rpx);
		}
		.content{
			background: #FFFFFF;
			height: calc(100vh - 170rpx);
			.project{
				background-color: #FFFFFF;
				padding: 0rpx 30rpx;
				// height: 150rpx;
				display: flex;
				align-items: center;
				padding-top: 40rpx;
				box-sizing: border-box;
				.image{
					width: 70rpx;
					height: 70rpx;
					margin-left: 29rpx;
					margin-right: 40rpx;
				}
				.name{
					.t1{
						font-size: 32rpx;
						font-weight: bold;
						color: #445469;
					}
					.t2{
						font-size: 28rpx;
						font-weight: 500;
						color: #6A819E;
						margin-top: 5rpx;
					}
				}
			}
			
			.box{
				padding: 0rpx 30rpx;
				background-color: #FFFFFF;
			}
			.nav{
				line-height: 100rpx;
				height: 100rpx;
				padding: 0rpx 28rpx;
				display: flex;
				justify-content: space-between;
				
				.name{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.value{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.width{
					width: 120rpx;
					text-align: center;
				}
			}
			.border{
				border-bottom: 1rpx solid #d6d7d9;
			}
			
			.center{
				background-color: #FBFDFF;
				padding: 32rpx 38rpx;
				padding-top: 12rpx;
				border-bottom: 2rpx solid #E2E5ED;
				.item{
					display: flex;
					margin-top: 20rpx;
					
					.name{
						width: 150rpx;
					}
				}
			}
		}
		.flow{
			margin-top: 30rpx;
			background-color: #FFFFFF;
			padding-left: 62rpx;
			padding-right: 72rpx;
			padding-top: 36rpx;
			.f-title{
				font-size: 30rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #22204E;
				margin-bottom: 54rpx;
			}
			.f-body{
				height: 200rpx;
				padding-left: 10rpx;
				display: flex;
				.user{
					flex: 1;
					.user-item{
						text-align: right;
						margin-bottom: 150rpx;
					}
					.userImg{
						width: 50rpx;
						height: 50rpx;
						vertical-align: middle;
						margin-right: 14rpx;
					}
					.username{
						font-size: 22rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #6A819E;
					}
						
				}
			}
		}
		
	}
</style>
<style>
	page{
		width: 100%;
		height: 100%;
	}
</style>
